home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
pdox35sc.zip
/
POPMENU.SC
< prev
next >
Wrap
Text File
|
1991-06-10
|
30KB
|
470 lines
;****************************************************************************************
; CREATING VERTICAL BOUNCE BAR MENUS
; Copyright 1991 Virginia B. Sauer All Rights Reserved
; This program may be copied/modified without charge provided both that this
; copyright notice is included without change, and that any accompanying
; documentation includes the notice "Portions of code (c) Copyright 1991,
; Virginia B. Sauer"
; ***************************************************************************************
; "Cosmetics" form an integral part of any application. The user's perception
; of a system is largely dependent upon its menu system and user interface.
; Generic vertical bounce bar menus can greatly enhance the Paradox interface.
; Although no more cumbersome than ShowMenu, they can immeasurably help to
; achieve a professional tone.
; The following procedures (Pop_Main, Pop_Menu, Highlight_Choice, and
; Key_Pressed) are totally generic - i. e., although they can be modified with
; respect to colors, et cetera, they will work with any Paradox program. Write
; them to a utility library to be available whenever needed.
; These procedures will be called from a menu procedure. A sample such proc
; appears at the end of this script. To invoke the procedure, type Main_Menu()
; (or whatever name you have selected for the menu in question).
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ PARAMETERS PASSED TO THIS PROCEDURE ║
; ╟───────────────┬────────────────────────┬─────────────────────────────────────────────╢
; ║ ARGUMENT │ DESCRIPTION │ EXAMPLE ║
; ╟───────────────┼────────────────────────┼─────────────────────────────────────────────╢
; ║ │ Your company's name as │ "T H E D E V E L O P E R ' S ║
; ║ │ it will appear at the │ T O O L B O X" ║
; ║ │ top of the menu │ ║
; ║ CompanyHeader │ (e. g., with any │ (to signify a company named The ║
; ║ │ desired spacing) │ Developer's Toolbox, to appear in upper ║
; ║ │ │ case, with one space between each ║
; ║ │ N. B. This must ap- │ character, and four spaces between each ║
; ║ │ pear in quotes. │ word) ║
; ╟───────────────┼────────────────────────┼─────────────────────────────────────────────╢
; ║ │ The name of your │ "D E M O N S T R A T I O N O F ║
; ║ │ system or application │ G E N E R I C U T I L I T I E S" ║
; ║ │ as it will appear on │ ║
; ║ │ your menu (e. g., │ ║
; ║ SystemHeader │ with any desired │ (to signify a demo application named ║
; ║ │ spacing) │ Demonstration of Generic Utilities, to ║
; ║ │ │ appear in upper case, with one space ║
; ║ │ N. B. This must ap- │ between each character, and four spaces ║
; ║ │ pear in quotes. │ between each word) ║
; ╟───────────────┼────────────────────────┼─────────────────────────────────────────────╢
; ║ │ The name of the menu │ ║
; ║ │ (e. g., Report Menu │ "M A I N M E N U" ║
; ║ │ for a report menu, or │ ║
; ║ MenuTitle │ Exit Menu for an exit │ (to signify the main menu, to appear ║
; ║ │ menu) │ in upper case, with one space between ║
; ║ │ │ each character, and four spaces between ║
; ║ │ N. B. This must ap- │ each word) ║
; ║ │ pear in quotes. │ ║
; ╚═══════════════╧════════════════════════╧═════════════════════════════════════════════╝
Proc Pop_Main(CompanyHeader,SystemHeader,MenuTitle)
; -------------- Set colors, variables, and menu choices
Cursor off
TextColor = 32 ; Black on green
BoxColor = 13 ; Light magenta on black
SelectColor = 90 ; Light green on magenta
UnselectColor = 10 ; Light green on black
KeyHelp1 = Format("W74,AC","Press , Home, End, and/or Space Bar to move highlight, and Enter to")
KeyHelp2 = Format("W74,AC","select (or, press bold letter of desired option to zoom directly there).")
MaxLength = Len(Choicelist[1]) + 2
BoxColumn = Round((80-MaxLength)/2,0)
MenuSize = ArraySize(ChoiceList)
TopRow = Round((25-(MenuSize + 4))/2,0)
Spacenum = Round((((Len(Choicelist[1])+2))-(Len(MenuTitle)+22))/4,0)
MenuTitle = Spaces(Spacenum) + " " + Spaces(SpaceNum)
+ MenuTitle + Spaces(SpaceNum) + " " + Spaces(Spacenum)
Pointer = 1
; -------------- Initialize Arrays/variables for menu choices / screen coordinates.
If MenuSize < 10
Then Numlines = 02
Else NumLines = 01
TopRow = (TopRow + 1)
Endif
Array MenuRow[MenuSize] ; MenuChoice Rows
For X From 1 to MenuSize
MenuRow[X] = (TopRow + NumLines + X)
EndFor
BoldColumn = (BoxColumn + 1) ; MenuChoice Bold Letters Columns
;--- Uncomment the next line if you are highlighting other than the first letter
; XBoldColumn = (BoxColumn + 2)
FirstRow = 01
LastRow = 23
BoxTop = (MenuRow[1] - 1)
BoxEnd = (MenuRow[MenuSize] + 1)
If MenuSize > 9
Then FirstRow = (FirstRow - 1)
LastRow = (LastRow + 1)
BoxTop = (BoxTop + 1)
BoxEnd = (BoxEnd - 1)
Endif
Pop_Menu()
EndProc
; -------------- Draw outer frame, menu box and static titles.
Proc Pop_Menu()
Clear Clearall
Paintcanvas Attribute 00 00, 00, 24, 79 Style attribute 15 ; black
Draw_Box("Double",05,FirstRow,02,LastRow,77,(FirstRow + 3),(LastRow - 3))
PaintCanvas Attribute 32 (FirstRow + 1), 03, (FirstRow + 2), 76 Style Attribute TextColor
@ (FirstRow + 1), Round((80-Len(CompanyHeader))/2,0) ?? CompanyHeader
@ (FirstRow + 2), Round((80-Len(SystemHeader))/2,0) ?? SystemHeader
@ (LastRow - 2), 03 ?? KeyHelp1
@ (LastRow - 1), 03 ?? KeyHelp2
Style attribute BoxColor
@ (TopRow - 1), (BoxColumn - 2) ?? "┌", Fill("─",(MaxLength + 2)), "┐"
@ (Row() + 1), (BoxColumn - 2) ?? "│", Fill(" ",(MaxLength + 2)), "│"
@ (Row() + 1), (BoxColumn - 2) ?? "├", Fill("─",(MaxLength + 2)), "┤"
For X From BoxTop to BoxEnd
@ X, (BoxColumn - 2) ?? "│"
@ X,((BoxColumn - 2) + (MaxLength + 3)) ?? "│"
EndFor
@ (Row() + 1), (BoxColumn - 2) ?? "└", Fill("─",(MaxLength + 2)), "┘"
PaintCanvas Attribute 32 TopRow, (BoxColumn-1), TopRow, ((MaxLength+2)+(BoxColumn-2)) Style Attribute TextColor
@ (TopRow ), Round((80-Len(MenuTitle))/2,0) ?? MenuTitle
Style Attribute UnselectColor
For X From 2 to MenuSize
@ MenuRow[X], (BoxColumn + 1) ?? ChoiceList[X]
EndFor
Style Attribute SelectColor
@ MenuRow[1], (BoxColumn + 1) ?? ChoiceList[1]
Key_Pressed()
Please_Wait("Please wait while information is being extracted.")
EndProc
; ----------- Highlight current option based on last keypress.
Proc Highlight_Choice()
Style Attribute UnselectColor
@ MenuRow[OldChoice], (BoxColumn + 1) ?? ChoiceList[OldChoice]
;--- Uncomment the following 5 lines if you are highlighting other than the first letter
; Style Attribute BoxColor
; If OldChoice = MenuSize
; Then @ MenuRow[OldChoice], XBoldColumn ?? Substr(ChoiceList[OldChoice],3,1)
; Else @ MenuRow[OldChoice], BoldColumn ?? Substr(ChoiceList[OldChoice],2,1)
; Endif
Style Attribute SelectColor
@ MenuRow[Pointer], (BoxColumn + 1) ?? ChoiceList[Pointer]
EndProc
; ----------- Act upon key pressed by user
Proc Key_Pressed()
While true
Style Attribute BoxColor
;--- Change this segment for each line highlighting other than first letter
;--- e. g., @ MenuRow[MenuSize], XBoldColumn ?? Substr(ChoiceList[MenuSize],2,1)
For X From 1 to (MenuSize)
@ MenuRow[X], BoldColumn ?? Substr(ChoiceList[X],1,1)
EndFor
OldChoice = Pointer
Highlight_Choice()
UserKey = Getchar()
Switch
Case Userkey >= 48
and Userkey <= 122: For X From 1 to MenuSize
If upper(substr(Choicelist[X],1,1)) = upper(chr(Userkey))
Then Pointer = X
Quitloop
Endif
EndFor
;--- Since many novices do not know how to exit from interactive
; Paradox, the next line traps the Escape key to exit to DOS
; (and/or the user's disk organizer / menu manager).
;--- Should you prefer to reassign the Escape key to either invoke
; your own exit routine or to exit to Paradox, change the word
; Exit to Quit on the following line.
Case UserKey = 27 : Pointer = MenuSize Highlight_Choice() Exit ; Escape
Case UserKey = 13 : Quitloop ; [ENTER] so exit Loop/branch to selection
Case UserKey = -71 : Pointer = 1 ; [Home]
Case UserKey = -79 : Pointer = MenuSize ; [End]
Case UserKey = -72 : If Pointer <> 1 ; [Up] - so,
Then Pointer = (Pointer - 1) ; unless first
Else Pointer = MenuSize ; option,
Endif ; Move-Highlight()
Case UserKey = -80 : If Pointer <> MenuSize ; [Down]
Then Pointer = (Pointer + 1)
Else Pointer = 1
Endif
Case UserKey = 32 : If Pointer <> MenuSize ; [Spacebar]
Then Pointer = (Pointer + 1)
Else Pointer = 1
Endif
EndSwitch
If Pointer <> X
then Highlight_Choice()
Loop
else Quitloop
Endif
EndWhile
Endproc
; ---------------------------------------------------------------------------------------
; SHOW MESSAGE TO PREVENT IMPATIENT USERS FROM WREAKING HAVOC
; (A generic procedure utilized by the printer utility, but useful in any application.)
; ---------------------------------------------------------------------------------------
Proc Please_Wait(WaitMssg) ; Tell user what is happening
Cursor Off ; Do not show cursor
Clear Clearall ; Clear screen and canvas
PaintCanvas Attribute 00 00, 00, 24, 79 ; Draw black background
PaintCanvas Attribute 112 10, 07, 14, 75 ; Draw grey shadow
PaintCanvas Attribute 48 09, 04, 13, 73 ; Draw cyan box
Style Attribute 176 ; Draw blinking black characters
@ 11,05 ?? " \07 \07 \07 " ; (Ascii code 7)
@ 11,66 ?? " \07 \07 \07 " ; (Ascii code 7)
Style Attribute 48 ; Show black lettering
@ 11,13 ?? Format("AC,CC,W52",Strval(Waitmssg)) ; Center message (capitalizing
Endproc ; first letter of each word)
; ---------------------------------------------------------------------------------------
; DRAW A COLORED BOX AT GIVEN COORDINATES
; (A generic procedure utilized by the printer utility, but useful in any application.)
; ---------------------------------------------------------------------------------------
Proc Draw_Box(LineType,BoxColor,StartRow,StartColumn,Endrow,EndColumn,FirstCross,NextCross)
Private FillNum, ; Number of horizontal characters to fill in
X ; A counter
; --- Determine the number of horizontal characters to fill in between starting and ending
; columns
Fillnum = (EndColumn - StartColumn -1)
; --- Determine appropriate character for each part of the box (e. g., for each type of
; line (single, double, and wide), the upper lefthand corner, upper right hand corner,
; lower left hand corner, lower right hand corner, horizontal, and vertical ... As the
; wide lines distinguish betwen horizontal "top" and "bottom" characters, both
; HorizontalTop and HorizontalBottom are cited.
Switch
Case Upper(LineType) = "SINGLE": UpperLeft = "\218" UpperRight = "\191"
LeftCross = "\195" RightCross = "\180"
LowerLeft = "\192" LowerRight = "\217"
HorizontalTop = "\196" HorizontalBottom = "\196"
Vertical = "\179"
Case Upper(LineType) = "DOUBLE": UpperLeft = "\201" UpperRight = "\187"
LeftCross = "\204" RightCross = "\185"
LowerLeft = "\200" LowerRight = "\188"
HorizontalTop = "\205" HorizontalBottom = "\205"
Vertical = "\186"
Case Upper(LineType) = "WIDE": UpperLeft = "\219" UpperRight = "\219"
LeftCross = "\219" RightCross = "\219"
LowerLeft = "\219" LowerRight = "\219"
HorizontalTop = "\223" HorizontalBottom = "\220"
Vertical = "\219"
EndSwitch
; --- Specify the color in which to draw the box
PaintCanvas Attribute BoxColor StartRow, StartColumn, EndRow, EndColumn Style Attribute BoxColor
; --- At the designated coordinate, draw the top line of the box
@ StartRow, StartColumn ?? UpperLeft, Fill(HorizontalTop,FillNum), UpperRight
; --- Fill in with vertical lines extending from the starting row to the ending row
For X From (StartRow + 1) to (EndRow - 1)
@ X,StartColumn ?? Vertical ; Vertical lines at the "starting" column
@ X,EndColumn ?? Vertical ; Vertical lines at the "ending" column
EndFor
; --- If applicable, add intersecting horizontal "crosslines"
If not isblank(FirstCross)
Then @ FirstCross, StartColumn ?? LeftCross, Fill(HorizontalTop,FillNum), RightCross
If not isblank(NextCross)
Then @ NextCross, StartColumn ?? LeftCross, Fill(HorizontalTop,FillNum), RightCross
Endif
Endif
@ EndRow, StartColumn ?? LowerLeft, Fill(HorizontalBottom,FillNum), LowerRight
Endproc
; --- If desired, an additional horizontal line may be drawn across the canvas (Since this is
; the exception rather than the rule, it is separated from the "main" box-making
; procedure to prevent wasting space with seldom- used variables)
Proc Cross_Line(LineType,StartRow,StartColumn,EndColumn)
Private FillNum, ; Number of characters to fill in
X ; A counter
; --- Determine the number of horizontal characters to fill in between starting and ending
; columns
Fillnum = (EndColumn - StartColumn -1)
; --- Determine appropriate "crossline" character for each part of the box (e. g., for
; each type of line (single, double, and wide), the left-hand side character, the
; right-hand side character, and the horizontal character)
Switch
Case Upper(LineType) = "SINGLE" : LeftCross = "\195" ; ├
HorizontalCross = "\196" ; ─
RightCross = "\180" ; ┤
Case Upper(LineType) = "DOUBLE" : LeftCross = "\204" ; ╠
HorizontalCross = "\205" ; ═
RightCross = "\185" ; ╣
Case Upper(LineType) = "WIDE" : LeftCross = "\219" ; █
HorizontalCross = "\223" ; ▀
RightCross = "\219" ; █
Case Upper(LineType) = "DOUBLESINGLE" : LeftCross = "\199" ; ╟
HorizontalCross = "\196" ; ─
RightCross = "\182" ; ╢
EndSwitch
; --- At the designated coordinate, draw the specified line
@ StartRow, StartColumn ?? LeftCross, Fill(HorizontalCross,Fillnum), RightCross
Endproc
;*******************************************************************************
; ***** This is a template, which must be modified for each menu in your application *****
; -- For each menu in your application, give this a suitable name (e. g., Proc
; Report_Menu, Proc System_Menu, etc.).
; -- Modify as directed below, depending upon the desired title, options, etc.
; (Obviously, you can use as many menus as desired in a given application -
; e. g., a Main_Menu, System_Menu, Report_Menu, and Exit_Menu.)
;*******************************************************************************
Proc Main_Menu()
While True
;-----------------------------------------------------------------------
; Modify the options as desired. (For example, if your menu has only
; 5 choices, Array Choicelist[5], and define Choicelist[1] - Choicelist[5].)
; Note that each line must begin and end with double quotation marks)
;-----------------------------------------------------------------------
Array Choicelist[6]
Choicelist[1] = "First option - e. g., View "
Choicelist[2] = "Second option - e. g., Add "
Choicelist[3] = "Third option - e. g., Edit "
Choicelist[4] = "Fourth Option - e. g., Locate "
Choicelist[5] = "Fifth Option - e. g., Change "
Choicelist[6] = "Sixth Option - e. g., Quit "
;-----------------------------------------------------------------------
; Modify parameters (Company Header, System Header, and Menu Title) as desired
; For example, change the company header to the name of your company,
; the system header to the name of your application, and the menu title to
; the particular menu - R E P O R T M E N U for a report menu, or whatever.
;-----------------------------------------------------------------------
; Company header, system header, and menu title
Pop_Main("T H E D E V E L O P E R ' S T O O L B O X",
"D E M O N S T R A T I O N O F G E N E R I C U T I L I T I E S",
"M A I N M E N U")
;-----------------------------------------------------------------------
; Branch to subroutine (based on returned value of Pointer). Insert approporiate
; commands (i. e., substituting the names of your own procedures, as in
; calling Report_Menu() rather than First_Option(), or whatever. Delete
; unnecessary options - e. g., delete option 6 if your menu offers only 5 options
;-----------------------------------------------------------------------
Switch
Case Pointer = 1 : First_Option() ; insert appropriate commands here
Case Pointer = 2 : Second_Option() ; insert appropriate commands here
Case Pointer = 3 : Third_Option() ; insert appropriate commands here
Case Pointer = 4 : Fourth_Option() ; insert appropriate commands here
Case Pointer = 5 : Fifth_Option() ; insert appropriate commands here
Case Pointer = 6 : Quit
Otherwise: Beep
Loop
Endswitch
;-----------------------------------------------------------------------------
; Most developers favor "cascading" menu systems, whereby each sub-menu
; returns to the preceding or calling menu. In some instances, you may
; prefer to instead return to the main menu, rather than to the menu in
; question. To do so, simply add the word QuitLoop here (on the line
; between EndSwitch and EndWhile) to signify that one is not to return to
; that particular menu.
;-----------------------------------------------------------------------------
Endwhile
Endproc
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ SAMPLE INVOCATION ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ (1) Procs Pop_Main, Pop_Menu, Highlight_Choice, and Key_Pressed are totally ║
; ║ generic ... Just write them to your utility library (or any library of your ║
; ║ choice). ║
; ║ ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ (2) Using the Main_Menu procedure as a template, create a separate menu for EACH ║
; ║ desired menu, modifying Main_Menu accordingly - e. g., Proc Main_Menu ║
; ║ (offering your application's main options), Proc System_Menu (offering its ║
; ║ main system options), Proc Report_Menu (offering all report options), and ║
; ║ Proc Exit_Menu (offering options to back up data before quitting, and - if ║
; ║ not runtime - asking if the user wants to exit to Paradox or DOS). ║
; ║ ║
; ║ Proc Exit_Menu() ║
; ║ While true ║
; ║ Array Choicelist [4] ║
; ║ Choicelist[1] = "BACK UP Back up data before quitting " ║
; ║ Choicelist[2] = "PARADOX Exit to Paradox " ║
; ║ Choicelist[3] = "DOS Exit system to DOS " ║
; ║ Choicelist[4] = "CANCEL Do not exit; return to program " ║
; ║ Pop_Main("T H E D E V E L O P E R ' S T O O L B O X", ║
; ║ "D E M O O F G E N E R I C U T I L I T I E S", ║
; ║ "E X I T M E N U") ║
; ║ Please_Wait("Please wait while information is being extracted.") ║
; ║ Switch ║
; ║ Case Pointer = 1 : Backup_Data("Demo","All","C:\\Demo","AT", "A") ║
; ║ Case Pointer = 2 : Quit ║
; ║ Case Pointer = 3 : Exit ║
; ║ Case Pointer = 4 : Quitloop ║
; ║ Otherwise : Beep ║
; ║ Loop ║
; ║ Endswitch ║
; ║ Endwhile ║
; ║ Endproc ║
; ║ ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ (3) To invoke, "call" this menu just as you would any procedure: Main_Menu() if ║
; ║ it is called Proc Main_Menu, Report_Menu() if it is called Proc Report_Menu, ║
; ║ etc. ║
; ║ ║
; ║ For example, Exit_Menu() to invoke the above example ║
; ║ ║
; ╚══════════════════════════════════════════════════════════════════════════════════════╝
; ╔══════════════════════════════════════════════════════════════════════════════════════╗
; ║ CONVERTING A SHOWMENU TO A POP_MENU ║
; ╟──────────────────────────────────────────────────────────────────────────────────────╢
; ║ ║
; ║ Proc Main_Menu() ║
; ║ While true ║
; ║ ShowMenu ║
; ║ "Backup" : "Back up files" ║
; ║ "Printer" : "Set printer defaults" ║
; ║ "Quit" : "Quit" ║
; ║ To Pointer ║
; ║ Switch ║
; ║ Case Pointer = "Backup" : Backup_Data("Demo","All","C:\\Demo","AT", "A") ║
; ║ Case Pointer = "Print" : Setup_Printer("Portrait","Pica","11", ║
; ║ "Printer","Yes") ║
; ║ Case Pointer = "Quit" : Exit_Menu() ║
; ║ Otherwise : Beep ║
; ║ Loop ║
; ║ EndSwitch ║
; ║ Endwhile ║
; ║ Endproc ║
; ║ ║
; ║ ║
; ║ THE SAME PROCEDURE AS A POP_MENU: ║
; ║ ║
; ║ ║
; ║ Proc Main_Menu() ║
; ║ While True ║
; ║ Array Choicelist[3] ║
; ║ Choicelist[1] = "Backup - Back up files " ║
; ║ Choicelist[2] = "Printer - Set printer defaults " ║
; ║ Choicelist[3] = "Quit - Quit" " ║
; ║ Pop_Main("T H E D E V E L O P E R ' S T O O L B O X", ║
; ║ "D E M O O F G E N E R I C U T I L I T I E S", ║
; ║ "M A I N M E N U") ║
; ║ Switch ║
; ║ Case Pointer = 1 : Backup_Data("Demo","All","C:\\Demo","AT", "A") ║
; ║ Case Pointer = 2 : Setup_Printer("Portrait","Pica","11", ║
; ║ "Printer","Yes") ║
; ║ Case Pointer = 3 : Exit_Menu() ║
; ║ Otherwise : Beep ║
; ║ Loop ║
; ║ Endswitch ║
; ║ Endwhile ║
; ║ Endproc ║
; ╚══════════════════════════════════════════════════════════════════════════════════════╝